<?php

declare(strict_types=1);
/**
 *​
 * 小程序问题反馈API
 * User：Abell
 * Date：2020/4/16
 * Time：11:11
 */

namespace App\Controller\Api;

use App\Controller\AbstractController;
use App\Utils\ApiUtils;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\Di\Annotation\Inject;
use App\Service\WxserviceService;
use App\Validate\WxserviceValidation;
use App\Constants\ErrorCode;

class WxserviceController extends AbstractController
{
    /**
     * @Inject
     * @var WxserviceService
     */
    protected $service;

    /** 小程序用户提交问题反馈
     * @Author abell
     * @DateTime 2020-05-27
     * @return object
     */
    public function formMsg(RequestInterface $request){
        if($request->isMethod('get')){
            return $this->jsonApi($this->service->formInfo());
        }else{
            make(WxserviceValidation::class)->check($request->all(),'form_msg')->response();
            return $this->jsonApi($this->service->formMsg($request->all()));
        }
    }

    /** 问题反馈类型列表获取
     * @Author abell
     * @DateTime 2020-05-27
     * @return object
     */
    public function getList(){
        $ope = $this->service->formOpe();
        $type = $this->service->formType();
        return $this->response->json(ApiUtils::send(ErrorCode::SUCCESS,ErrorCode::getMessage(ErrorCode::SUCCESS),['ope'=>$ope,'type'=>$type],1));
    }


}